import Vue from 'vue'
import App from './App.vue'

import VisualDesign from '@/../lib/VFormDesigner.umd'
import '@/../lib/VFormDesigner.css'
Vue.use(VisualDesign)

import Avue from '@smallwei/avue';
import '@smallwei/avue/lib/index.css';
Vue.use(Avue);

import Vuex from 'vuex'
Vue.use(Vuex)

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);


import axios from 'axios'
Vue.use(Avue,{axios})

import  "./assets/css/reset.css"
import  "./assets/css/bootstrap.min.css"
import router from "@/router";

import '@/assets/iconfont/iconfont.css'

import VueCoreVideoPlayer from 'vue-core-video-player'
Vue.use(VueCoreVideoPlayer)

//脱敏
import regular from "./utils/dataDesensi";
Vue.prototype.regular = regular;

//注入全局验证
import {validateNumber} from "./utils/validate";
Vue.prototype.$validateNumber = validateNumber;

// 图片预览
import Viewer from "v-viewer";
import "viewerjs/dist/viewer.css";
Vue.use(Viewer);

//vant
import {Field,Form} from 'vant' ;
Vue.use(Field)
Vue.use(Form)

//i18n
// import i18n from "@/utils/i18n" // Internationalization

import VueI18n from "vue-i18n";
Vue.use(VueI18n) ;
const i18n = new VueI18n({
  locale:'en',
  messages:{
    en:{txt:'英文',loading:{color:'{msg}red'}},
    zh:{txt:'中文',loading:{color:'{msg}红色'}}
  }
})

Vue.use(ElementUI, {
  i18n: (key, value) => i18n.t(key, value),
})



Vue.config.productionTip = false

import Treeselect from '@riophae/vue-treeselect' // 导入vue-treeselect
import '@riophae/vue-treeselect/dist/vue-treeselect.css' // 导入样式

Vue.component('Treeselect', Treeselect); // 注册组件


import permission from "@/components/hrvue/permission";
import {APP_ROOT_RESOURE,NOTFOUND_URL,VUE_APP_LOCAL_MENU} from "@/components/hrvue/constant";
Vue.use(permission,{router,APP_ROOT_RESOURE,NOTFOUND_URL,VUE_APP_LOCAL_MENU,
  useCustomRequest:() => {

  }
})

import store from "./store";

import HrUpload from "@/components/upload/index"
Vue.use(HrUpload) ;



new Vue({
  render: h => h(App),
  router,
  store,
  i18n,
}).$mount('#app')

/**
 * 在第一次点击后禁用按钮，避免重复提交数据
 * 在控件在增加 v-no-db-click="毫秒数"进行绑定
 */
Vue.directive("noDbClick", {
  inserted(el, binding) {
    el.addEventListener("click", (e) => {
      if (!el["disabled"]) {
        el.disabled = true
        let oldText = el.innerHTML
        el.innerHTML = `<span><i class="el-icon-loading"></i>请等待</span>`
        el.style.cursor = "not-allowed"
        let seconds = binding.value
        if (!seconds) {
          seconds = 2000
        }
        setTimeout(() => {
          el.style.cursor = "pointer"
          el.innerHTML = oldText
          el.disabled = false
        }, seconds)
      }
    })
  },
})





